const version="1.0.5"
/**
 * Created by jun on 2017/6/29.
 */
var args=process.argv.slice(2);
var startParam={};
for(var i=0;i<args.length;i++){
    var tem=args[i].split("=");
    if(tem&&tem.length==2){
        startParam[tem[0]]=tem[1];
    }
}
require("../base/Class.js");
// var arguments = process.argv.splice(2);
var logManager=require("./Logs.js");
logManager.init(startParam["--debug"]=="true")

// logStact=function(arg){    logManager.logStact(arg);}
// logW=function(msg){    logManager.logW(msg);}
// logM=function(msg){    logManager.logM(msg);}
// logE=function(msg){    logManager.logE(msg);}
// logObj=function(msg){    logManager.logObj(msg);}
// logP=function(msg){    logManager.logP(msg);}

var Manager={
    eventManager:new (require("./EventManager.js")),// require [logManager],
    timerManager:new (require("./TimerManager.js")),// require [logManager],
    httpManager:new (require("./HttpManager.js")),// require [logManager,eventManager],
    socketManager:new (require("./SocketManager.js")),//require [logManager,eventManager],
    tcpSocketManager:new (require("./TcpSocketManager.js")),// require [logManager,eventManager],
    moduleManager:new (require("./ModuleManager.js")),// require [logManager,httpManager,eventManager],
    logManager:logManager,
    errorHandler:require("./ErrorCatch.js"),
    httpUtils:require("../utils/HttpUtils.js"),
    fileUtils:require("../utils/FileUtils.js"),
    utils:require("../utils/Utils.js"),
    init:function(){
        logManager.logM("framework initialization:"+version);
        Manager.errorHandler.init();
        Manager.eventManager.init();
        Manager.timerManager.init();
        Manager.socketManager.init(Manager.eventManager);
        Manager.tcpSocketManager.init(Manager.eventManager);
        Manager.httpManager.init(Manager.eventManager);
        Manager.moduleManager.init(Manager.eventManager,Manager.httpManager);
    },
    /**
     * @param time delay ms
     * @returns {Promise<unknown>}
     */
    sleep:async function(time){
        return new Promise(function(resolve,reject){
            setTimeout(resolve,time);
        })
    }
}
module.exports=Manager;